//项目用户相关的请求地址

import request from '@/utils/request'

// 引入接口类型 --mock的
// import type {
//   loginFormData,
//   loginResponseData,
//   userInfoResponseData,
// } from './type'

import type {
  loginFormData,
  loginResponseData,
  userInfoResponseData,
} from './type'

enum API {
  // mock 数据
  // LOGIN_URL = 'user/login',
  // USERINFO_URL = 'user/info',

  // 真实接口
  LOGIN_URL = '/admin/acl/index/login',
  USERINFO_URL = '/admin/acl/index/info',
  LOGOUT_URL = '/admin/acl/index/logout',
}

//
export const reqUserInfo = () => {
  return request.get<any, userInfoResponseData>(API.USERINFO_URL)
}

//  loginFormData和loginResponseData为模拟数据接口类型
export const reqLogin = (data: loginFormData) => {
  // loginResponseData 定义的是接口返回的数据类型
  return request.post<any, loginResponseData>(API.LOGIN_URL, data)
}

// 退出登录
export const reqLogout = () => {
  return request.post<any, any>(API.LOGOUT_URL)
}
